#ifndef __WIN_SOCKET_H__
#define __WIN_SOCKET_H__



#ifdef _WIN32
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#else
#include <unistd.h>
#include <arpa/inet.h>
#endif
#include "qelib.h"

enum {
    WIN_SOCKET_UDP = 0,
    WIN_SOCKET_TCP = 1,
};

typedef struct
{
    WSADATA ws;
    SOCKET s;
    SOCKADDR_IN server_addr;
    SOCKADDR_IN client_addr;
    int client_addr_len;
} win_socket;



qe_ret win_socket_init(win_socket *sock, int proto, const char *address, qe_u16 port);
qe_ret win_socket_bind(win_socket *sock);
qe_ret win_socket_send(win_socket *sock, char *buf, int size);
qe_ret win_socket_recv(win_socket *sock, char *buf, int size, int *rxsize);
void win_socket_exit(win_socket *sock);



#endif /* __UDP_SOCKET_H__ */